package cn.netjava.wk;



import java.io.File;
import java.io.IOException;

public class FileCreate  {	
	String dir, filename,fileordir,  setattribute=null;
	public FileCreate(String dir, String filename,String fileordir,String setattribute){
		this.dir=dir;
		this.filename=filename;
		this.fileordir=fileordir;
		this.setattribute=setattribute;
	
	}
	
	
	
	
	/*
	 * @param createrFile @value String directory,String prefilename,String
	 * subfilename,String set
	 *  @return boolean
	 */
	

	public boolean createFile() {				
		
		try {			
			File ff=new File(dir+File.separator+filename);
			if(fileordir.equalsIgnoreCase("file")){
			ff.createNewFile();			 
			
			}else if(fileordir.equalsIgnoreCase("dir")){
				ff.mkdir();
			};
			if(setattribute.equalsIgnoreCase("canread")){
				ff.setReadable(true);
			}else if(setattribute.equalsIgnoreCase("canwrite")){
				ff.setWritable(true);
			}
			return ff.exists();
		} catch (Exception e) {
			e.printStackTrace();
		    return false;
		}		
	
	}

}
